package com.wj.service.impl;

import com.wj.domain.entity.ChapterContentEntity;
import com.wj.domain.vo.ChapterContentVO;
import com.wj.infrastructure.repository.ChapterContentRepository;
import com.wj.service.ChapterContentService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Optional;

@Service
public class ChapterContentServiceImpl implements ChapterContentService {

    @Resource
    private ChapterContentRepository chapterContentRepository;

    @Override
    public ChapterContentVO getById(Long contentId) {
        ChapterContentVO chapterContent = new ChapterContentVO();
        Optional<ChapterContentEntity> optional = chapterContentRepository.findById(contentId);
        if (optional.isPresent()){
            ChapterContentEntity entity = optional.get();
            BeanUtils.copyProperties(entity, chapterContent);
        }
        return chapterContent;
    }
}